package cn.cs.message.tempstorage.disk;

import java.nio.ByteBuffer;

import cn.cs.message.Message;
import cn.cs.message.MessageClient;

public class MsgEncoder 
{
	private byte[] content;
	
	public int size()
	{
		return 4+content.length;
	}
	
	public MsgEncoder(Message msg)
	{
		this.content=MessageClient.getBytes(msg);
	}
	
	public void encode(ByteBuffer buffer)
	{
		buffer.putInt(content.length);
		buffer.put(content);
	}
}
